<template>
	<view :style="themeColor">
		<view class="page">

			<view class="flex flex-direction flex-wrap align-center justify-center benben-flex-layout ccddLogin_flex_0">
				<image class='ccddLogin_fd0_0' mode="aspectFill" src='/static/images/logo1.png'></image>
			</view>


			<!---登录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout ccddLogin_flex_1">
				<view class='flex flex-wrap align-center ccddLogin_fd1_0'>
					<image class='ccddLogin_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"285.png"'></image>
					<benben-input class='flex-sub ccddLogin_fd1_0_c1' type="number" :placeholder="`请输入手机号`"
						confirm-type="done" :maxlength="11"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="mobile" />
				</view>
				<view class='flex flex-wrap align-center ccddLogin_fd1_0'>
					<image class='ccddLogin_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"286.png"'></image>
					<benben-input class='flex-sub' type="number" :placeholder="`请输入验证码`" confirm-type="done"
						:maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
						v-model="code" />
					<benben-send-verification-code key='1681875393041' ref="vCode1681875393041"
						class=' ccddLogin_fd1_1_c2' after-text='后重新获取' before-text='获取验证码' type='3'
						:phone="mobile"></benben-send-verification-code>
				</view>
				<text class='self-end ccddLogin_fd1_2' @tap.stop="handleJumpDiy" data-type="redirectTo"
					:data-url="`/pages/tabBar/login/login?type=${type}`">密码登录</text>
				<view class='flex flex-wrap align-center justify-center'>
					<button class='ccddLogin_fd1_3_c0' @tap.stop="verificationCodeLoginFunc()">登录</button>
				</view>
				<view class='flex flex-wrap align-center justify-center ccddLogin_fd1_4'>
					<text class='ccddLogin_fd1_4_c0' @tap.stop="handleJumpDiy" data-type="redirectTo"
						:data-url="`/pages/login/registers/registers?type=${type}`">注册账号 </text>
					<view class='flex flex-wrap align-center ccddLogin_fd1_4_c1'>
					</view>
					<text class='ccddLogin_fd1_4_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/forgetPassword/forgetPassword`">忘记密码</text>
				</view>
			</view>

			<!---登录flex布局结束-->
			<benben-popup v-model="popupShow1710750049220" :mask="true" :mask-close-able="false" mode='center'
				:z-index='999'>
				<!---退出登录flex布局开始-->
				<view class="flex flex-direction flex-wrap align-center ccddLogin_flex_2"
					@tap.stop="popupShow1650940432200=true">
					<text class='ccddLogin_fd2_0'>该账号已申请注销</text>
					<text class='ccddLogin_fd2_1'>是否取消注销？</text>
					<view class='flex flex-wrap align-center ccddLogin_fd2_2'>
						<button class='ccddLogin_fd2_2_c0' @tap.stop="popupShow1710750049220=false">否</button>
						<button class='ccddLogin_fd2_2_c1' @tap.stop="setRevocationFunc()">是</button>
					</view>
				</view>

				<!---退出登录flex布局结束-->

			</benben-popup>
			<view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex ccddLogin_flex_3">
				<view
					v-if="(appSystemIdentification=='Android' || appSystemIdentification=='IOS' || appSystemIdentification=='Web') && typeee != 1">
					<view class='flex flex-wrap align-center justify-center ccddLogin_fd3_0'>
						<view class='flex  ccddLogin_fd3_0_c0'></view>
						<text class='ccddLogin_fd3_0_c1'>快捷登录</text>
						<view class='flex  ccddLogin_fd3_0_c0'></view>
					</view>
					<view class='flex flex-wrap align-center justify-center ccddLogin_fd3_1'>
						<image class='ccddLogin_fd3_1_c0' mode="aspectFit" :src='STATIC_URL+"154.png"'
							@tap.stop="wxLoginFunc()"></image>
					</view>
				</view>
				<view class='flex flex-wrap align-stretch justify-center ccddLogin_fd3_2'>
					<benben-flex-switch-new class-name='flex flex ccddLogin_fd3_2_c0' v-model="select"
						:disabled='false'>
						<template v-slot:checked>
							<view class='flex flex position-relative align-center'>
								<image class='ccddLogin_checkfd3_2_c0_c0_c0' mode="aspectFit"
									:src='STATIC_URL+"133.png"'></image>
							</view>
						</template>
						<template v-slot:unchecked>
							<view class='flex flex position-relative justify-end align-center'>
								<image class='ccddLogin_noCheckfd3_2_c0_c1_c0' mode="aspectFit"
									:src='STATIC_URL+"156.png"'></image>
							</view>
						</template>
					</benben-flex-switch-new>
					<text class='ccddLogin_fd3_2_c1'>已阅读并同意</text>
					<text class='ccddLogin_fd3_2_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/agreements/agreements`">《用户协议》</text>
					<text class='ccddLogin_fd3_2_c1'>与</text>
					<text class='ccddLogin_fd3_2_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/policy/policy`">《隐私政策》</text>
				</view>
			</view>
			<view :style="{height: '400rpx'}"></view>
		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"popupShow1710750049220": false,
				"typeee": 1,
				"switchData": {
					"aid": "",
					"sys_num": "",
					"sys_time": ""
				},
				"mobile": "",
				"type": "",
				"code": "",
				"is_tick": false,
				"codeLoginData": {
					"userinfo": {
						"user_token": "",
						"member_id": "",
						"id": "",
						"account": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"client_id": "",
						"phone": "",
						"user_type": "",
						"shopID": ""
					}
				},
				"select": false,
				"copyright": {
					"project_name": "",
					"copyright_info": "",
					"create_time": "",
					"logo": ""
				}
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			/**
			 * @returns 
			 * Android       安卓
			 * IOS       苹果
			 * Web       H5 或 pc
			 * Wechat       微信小程序
			 * Alipay       支付宝小程序
			 * Baidu       百度小程序
			 * ByteBounce       抖音小程序
			 * 360       360小程序
			 * FastApp       快应用
			 */
			appSystemIdentification() {
				return this.$store.state.appSystemIdentification
			}
		},
		watch: {},
		onLoad(options) {
			let {
				type
			} = options
			if (type !== undefined) this.type = type
			this.getCopyrightFunc()

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.getSwitchFunc()
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取上架开关
			async getSwitchFunc() {
				//请求方法
				//数据验证

				let dataswitchData = await this.$api.get(global.apiUrls.post643e0feac967e, {

				});

				if (dataswitchData.data.code != 1) {
					this.$message.info(dataswitchData.data.msg);
					return
				}
				let infoswitchData = dataswitchData.data;
				this.switchData = infoswitchData.data
				this.typeee = this.switchData.switch
			},
			//验证码登录
			async verificationCodeLoginFunc() {
				if (!validate(this.mobile, 'require')) {
					this.$message.info('手机号不能为空');
					return false;
				}
				if (!validate(this.mobile, 'phone')) {
					this.$message.info('请输入正确的手机号');
					return false;
				}
				if (!validate(this.code, 'require')) {
					this.$message.info('验证码不能为空');
					return false;
				}
				if (!validate(this.code, 'captcha')) {
					this.$message.info('请输入正确的验证码');
					return false;
				}
				if (this.select === false) {
					this.$message.info('请先阅读并同意《用户协议》与《隐私政策》');
					return false;
				}
				let datacodeLoginData = await this.$api.dbPost(global.apiUrls.post5c78dca45ebc1, {
					mobile: this.mobile,
					code: this.code,
					user_type: '1'
				});
				if (!datacodeLoginData) return
				if (datacodeLoginData.data.code == -999) {
					this.popupShow1710750049220 = true
					return
				}
				if (datacodeLoginData.data.code != 1) {
					this.$message.info(datacodeLoginData.data.msg);
					return
				}
				let infocodeLoginData = datacodeLoginData.data;
				this.codeLoginData = infocodeLoginData.data
				this.$store.commit('updateUserInfo', this.codeLoginData.userinfo)
				this.$store.commit('saveToken', this.codeLoginData.userinfo.user_token)
				this.getClient()
				if (this.type == 1) {
					this.$urouter.switchTab(`/pages/tabBar/index/index`);
				} else {
					this.$urouter.navigateBack(1)
				}
			},
			//消息推送
			getClient() {
				/* 获取设备ID用作消息推送 start */
				// #ifdef APP-PLUS
				let client_id = plus.push.getClientInfo().clientid;
				console.log('设备client_id：' + client_id);
				if (client_id) {
					this.$api.post(global.apiUrls.post6655424618774, {
							client_id: client_id,
							client_type: this.appSystemIdentification == 'Android' ? 1 : 2
						})
						.then(result => {
							console.log('设备储存', result);
						});
				}
				// #endif
				/* 获取设备ID end */
			},
			//获取版权信息
			async getCopyrightFunc() {
				//请求方法
				//数据验证

				let datacopyright = await this.$api.get(global.apiUrls.post63ec8b1e9b32b, {
					aid: '1'
				});

				if (datacopyright.data.code != 1) {
					this.$message.info(datacopyright.data.msg);
					return
				}
				let infocopyright = datacopyright.data;
				this.copyright = infocopyright.data

			},
			//APP微信快捷登录
			wxLoginFunc() {
				if (this.select === false) {
					this.$message.info('请先阅读并同意《用户协议》与《隐私政策》');
					return false;
				}
				const self = this;
				uni.getProvider({
					service: 'oauth',
					success: function(res) {
						// self.$message.info('res', ~res.provider.indexOf('weixin'));
						console.log('res', res, ~res.provider.includes("weixin"))
						if (~res.provider.includes("weixin")) {
							console.log('rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr');
							uni.login({
								provider: 'weixin',
								success: function(loginRes) {
									console.log('eeeeeeeeeeeeeeee');
									// 获取用户信息
									uni.getUserInfo({
										provider: 'weixin',
										success: function(info) {
											// console.log(info);
											let openid = info.userInfo.openId;
											let unionid = info.userInfo.unionId;
											var datas = {
												unionid: unionid,
												openid: openid,
												type: 'wx_app',
												user_type: '1'
											};
											console.log(datas);
											self.$api.post(global.apiUrls
													.post5d7660a421e69, datas)
												.then(ret => {
													if (ret.data.code == 1) {
														var data = ret.data.data
															.userinfo;
														console.log(ret,
															'这是接口反馈书库');
														self.$store.commit(
															'updateUserInfo',
															data);
														self.$store.commit(
															'saveToken', data
															.user_token);
														self.getClient()
														uni.showToast({
															title: '登录成功',
															icon: 'none',
															mask: true,
															duration: 500
														})
														if (self.type == 1) {
															console.log(
																'2222222222222'
															);
															self.$urouter
																.switchTab(
																	`/pages/tabBar/index/index`
																);
														} else {
															console.log(
																'333333333333');
															self.$urouter
																.navigateBack(1)
														}
													} else if (ret.data.code ==
														3) {
														console.log(ret,
															'这是接口反馈书库');
														uni.showToast({
															title: '未绑定手机号,前去绑定',
															icon: 'none',
															mask: true,
															duration: 500
														});
														uni.navigateTo({
															url: '/pages/login/bindMobilePhone/bindMobilePhone?openid=' +
																openid +
																'&source=' +
																1 +
																'															&unionid=' +
																unionid +
																'&type=' +
																1
														});
													}
												})
												.catch(err => {
													console.log('catech====',
														err);
												});

										}
									})
								},
								fail(rea) {
									console.log(rea, '我错了');
								}
							})
						}
					},
					fail(rea) {
						console.log(rea, '我错了');
					}
				})
			},
			//撤销注销申请
			async setRevocationFunc() {
				//请求方法
				//数据验证

				let data65af32616116b = await this.$api.dbGet(global.apiUrls.post65af32616116b, {
					mobile: this.mobile
				});
				if (!data65af32616116b) return
				if (data65af32616116b.data.code != 1) {
					this.$message.info(data65af32616116b.data.msg);
					return
				}
				this.popupShow1710750049220 = false;
				setTimeout(() => {
					this.verificationCodeLoginFunc()
				}, 1000)
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
		background-size: 100% auto;
	}

	.ccddLogin_flex_0 {
		padding: 110rpx 0rpx 80rpx 0rpx;
	}

	.ccddLogin_fd0_0 {
		width: 505rpx;
		height: 150rpx;
	}

	.ccddLogin_flex_1 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.ccddLogin_fd1_4_c2 {
		font-size: 28rpx;
		font-weight: 400;
		color: #999999;
	}

	.ccddLogin_fd1_4_c1 {
		background: rgba(153, 153, 153, 1);
		width: 1rpx;
		height: 24rpx;
		background-size: 100% auto !important;
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.ccddLogin_fd1_4_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	.ccddLogin_fd1_4 {
		line-height: 34rpx;
		margin: 40rpx 0rpx 0rpx 0rpx;
	}

	.ccddLogin_fd1_3_c0 {
		background: var(--benbenbgColor2);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 500;
		width: 638rpx;
	}

	.ccddLogin_fd1_2 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 32rpx 0rpx 48rpx 0rpx;
	}

	.ccddLogin_fd1_1_c2 {
		line-height: 33rpx;
		text-align: center;
		font-size: 28rpx;
		color: var(--benbenFontColor4);
	}

	.ccddLogin_fd1_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
	}

	.ccddLogin_fd1_0_c0 {
		width: 34rpx;
		height: 34rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 28rpx 0rpx 0rpx;
	}

	.ccddLogin_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 40rpx 0rpx;
	}

	.ccddLogin_flex_2 {
		background: #fff;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.ccddLogin_fd2_2_c1 {
		border-top: 1px solid rgba(238, 238, 238, 1);
		border-left: 1px solid rgba(238, 238, 238, 1);
		background: #fff;
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: rgba(48, 144, 255, 1);
		width: 264rpx;
	}

	.ccddLogin_fd2_2_c0 {
		border-top: 1px solid #eee;
		background: #fff;
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		padding: 0rpx 103rpx 0rpx 103rpx;
	}

	.ccddLogin_fd2_2 {
		margin: 37rpx 0rpx 0rpx 0rpx;
	}

	.ccddLogin_fd2_1 {
		line-height: 44rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.ccddLogin_fd2_0 {
		font-size: 36rpx;
		font-weight: 800;
		line-height: 44rpx;
		color: #333333;
		margin: 40rpx 0rpx 40rpx 0rpx;
	}

	.ccddLogin_flex_3 {
		width: 750rpx;
		height: 400rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.ccddLogin_fd3_2_c2 {
		color: var(--benbenbgColor2);
		font-size: 22rpx;
		font-weight: 400;
		line-height: 32rpx;
	}

	.ccddLogin_fd3_2_c1 {
		color: var(--benbenFontColor0);
		font-size: 22rpx;
		font-weight: 400;
		line-height: 32rpx;
	}

	.ccddLogin_noCheckfd3_2_c0_c1_c0 {
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		width: 31rpx;
		height: 31rpx;
	}

	.ccddLogin_checkfd3_2_c0_c0_c0 {
		width: 31rpx;
		height: 31rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	::v-deep .ccddLogin_fd3_2_c0 {
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.ccddLogin_fd3_2 {
		margin: auto 0rpx 60rpx 0rpx;
	}

	.ccddLogin_fd3_1_c0 {
		width: 80rpx;
		height: 80rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.ccddLogin_fd3_1 {
		margin: 42rpx 0rpx 0rpx 0rpx;
	}

	.ccddLogin_fd3_0_c1 {
		color: var(--benbenFontColor2);
		font-size: 26rpx;
		font-weight: 400;
		line-height: 37rpx;
		margin: 0rpx 10rpx 0rpx 10rpx;
	}

	.ccddLogin_fd3_0_c0 {
		background: #EEEEEE;
		width: 156rpx;
		height: 1rpx;
		margin: 10rpx 0rpx 10rpx 0rpx;
		transform: scaleY(0.5);
		border-radius: 1rpx 1rpx 1rpx 1rpx;
	}

	.ccddLogin_fd3_0 {
		margin: 110rpx 0rpx 0rpx 0rpx;
	}
</style>